package com.hyt.it.ogt.opertaion.track.util;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author 朱振宇
 * @since 2022-11-23
 */
public class DateUtils {

    public static String now() {
        return DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(LocalDateTime.now());
    }

    public static String nowMillSecond() {
        return DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS").format(LocalDateTime.now());
    }

    public static LocalDateTime convert(String source) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        return LocalDateTime.parse(source,formatter);
    }

    public static String convertDateToString(LocalDateTime localDateTime){
        DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
        return dtf2.format(localDateTime);
    }
}
